<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:jsf="http://xmlns.jcp.org/jsf"
      xmlns:o="http://omnifaces.org/ui"
      xmlns:of="http://omnifaces.org/functions">
    <h:head>
    </h:head>

    <h:body>
        <ui:composition template="/dataverse_template.xhtml">
            <ui:param name="pageTitle" value="#{bundle.account} - #{dataverseServiceBean.findRootDataverse().name}"/>
            <ui:param name="dataverse" value="#{dataverseServiceBean.findRootDataverse()}"/>
            <ui:param name="showDataverseHeader" value="false"/>
            <ui:param name="loginRedirectPage" value="dataverseuser.xhtml"/>
            <ui:define name="body">
                <script>
                    //<![CDATA[
                    window.onpageshow = function(event) {
                        if (event.persisted) {
                            window.location.reload();
                        }
                    };
                    //]]>
                </script>
                <f:loadBundle basename="propertyFiles.Bundle" var="bundle"/>
                <f:metadata>
                    <f:event type="preRenderView" listener="#{facesContext.externalContext.response.setHeader('Cache-Control', 'no-cache, no-store')}"/>
                    <f:viewParam name="editMode" value="#{DataverseUserPage.editMode}"/>
                    <f:viewParam name="redirectPage" value="#{DataverseUserPage.redirectPage}"/>
                    <f:viewParam name="selectTab" value="#{DataverseUserPage.selectTab}"/>
                    <f:viewAction action="#{dataverseSession.updateLocaleInViewRoot}"/>
                    <f:viewAction action="#{DataverseUserPage.init}" />
                    <f:viewAction action="#{dataverseHeaderFragment.initBreadcrumbs(dataverseServiceBean.findRootDataverse(), (DataverseUserPage.editMode == 'CREATE' ? bundle['user.createBtn'] : bundle.account))}"/>
                </f:metadata>
                <h:form id="dataverseUserForm">

                    <p:focus context="dataverseUserForm"/>
                    <div class="clearfix" jsf:rendered="#{empty DataverseUserPage.editMode}">
                        <div class="btn-group pull-right" jsf:rendered="#{DataverseUserPage.passwordEditable or DataverseUserPage.accountDetailsEditable}">
                            <button type="button" id="editAccount" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                <ui:fragment rendered="#{DataverseUserPage.accountDetailsEditable}">
                                    <span class="glyphicon glyphicon-pencil"/> #{bundle['account.edit']}
                                </ui:fragment>
                                <ui:fragment rendered="#{! DataverseUserPage.accountDetailsEditable}">
                                    #{bundle['account.info']}
                                </ui:fragment>
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu pull-right text-left" role="menu">
                                <ui:fragment rendered="#{DataverseUserPage.passwordEditable or DataverseUserPage.accountDetailsEditable}">
                                    <li>
                                        <p:commandLink id="editAccount" rendered="#{DataverseUserPage.accountDetailsEditable}"
                                                       actionListener="#{DataverseUserPage.edit}" update="@form" oncomplete="javascript:bind_bsui_components();">
                                            <h:outputText value="#{bundle['account.info']}" />
                                        </p:commandLink>
                                    </li>
                                    <li>
                                        <p:commandLink id="changePassword" rendered="#{DataverseUserPage.passwordEditable}" 
                                                       actionListener="#{DataverseUserPage.changePassword}" update="@form" oncomplete="javascript:bind_bsui_components();">
                                            <h:outputText value="#{bundle.passwd}" />
                                        </p:commandLink>
                                    </li>
                                </ui:fragment>
                            </ul>
                        </div>
                    </div>

                    <p:panel rendered="#{DataverseUserPage.editMode == 'FORGOT'}">
                        <h:outputText value="#{bundle['user.lostPasswdTip']}" />
                    </p:panel>

                    <p:tabView id="dataRelatedToMeView" activeIndex="#{DataverseUserPage.activeIndex}" dynamic="true" rendered="#{empty DataverseUserPage.editMode}">
                        <p:ajax event="tabChange" listener="#{DataverseUserPage.onTabChange}" update="@all" oncomplete="javascript:bind_bsui_components();" />
                        <p:tab id="myData" title="#{bundle['user.dataRelatedToMe']}">
                            <ui:include src="mydata_fragment.xhtml"></ui:include>
                        </p:tab>
                        <p:tab id="notifications" title="#{bundle['header.user.selectTab.notifications']}">
                            <div class="table-container">
                                <ui:repeat value="#{DataverseUserPage.notificationsList}" var="item">
                                    <div class="notification-item #{item.displayAsRead ? '' : 'bg-warning'}">
                                        <div class="notification-item-cell">
                                            <ui:fragment rendered="#{item.theObject == null}">
                                                 <h:outputText value="#{bundle['notification.generic.objectDeleted']}" />
                                            </ui:fragment>
                                            <ui:fragment rendered="#{item.theObject != null}">
                                                <ui:fragment rendered="#{item.type == 'CREATEACC'}">
                                                    <span class="icon-dataverse text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.welcome']}" escape="false">
                                                        <o:param>
                                                            <h:outputText value="#{dataverseServiceBean.findRootDataverse().name}"/>
                                                        </o:param>
                                                        <o:param>
                                                            <a href="#{systemConfig.guidesBaseUrl}/#{systemConfig.guidesVersion}/user/index.html" title="#{dataverseServiceBean.findRootDataverse().name} #{bundle['header.guides.user']}" target="_blank">#{bundle['header.guides.user']}</a>
                                                        </o:param>
                                                        <o:param>
                                                            <a href="https://demo.dataverse.org">#{bundle['notification.demoSite']}</a>
                                                        </o:param>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'CREATEDV'}">
                                                    <span class="icon-dataverse text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.createDataverse']}" escape="false">
                                                        <o:param>
                                                            <a href="/dataverse/#{item.theObject.getAlias()}" title="#{item.theObject.getDisplayName()}">#{item.theObject.getDisplayName()}</a>
                                                        </o:param>
                                                        <o:param>
                                                            <a href="/dataverse/#{item.theObject.getOwner().getAlias()}" title="#{item.theObject.getOwner().getDisplayName()}">#{item.theObject.getOwner().getDisplayName()}</a>
                                                        </o:param>
                                                        <o:param>
                                                            <a href="#{systemConfig.guidesBaseUrl}/#{systemConfig.guidesVersion}/user/dataverse-management.html" title="#{bundle['notification.dataverse.management.title']}" target="_blank">#{bundle['header.guides.user']}</a>
                                                        </o:param>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'CREATEDS'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.createDataset']}" escape="false">
                                                        <o:param>
                                                            <a href="/dataset.xhtml?persistentId=#{item.theObject.getDataset().getGlobalId()}" title="#{item.theObject.getDataset().getDisplayName()}">#{item.theObject.getDataset().getDisplayName()}</a>
                                                        </o:param>
                                                        <o:param>
                                                            <a href="/dataverse/#{item.theObject.getDataset().getOwner().getAlias()}" title="#{item.theObject.getDataset().getOwner().getDisplayName()}">#{item.theObject.getDataset().getOwner().getDisplayName()}</a>
                                                        </o:param>
                                                        <o:param>
                                                            <a href="#{systemConfig.guidesBaseUrl}/#{systemConfig.guidesVersion}/user/dataset-management.html" title="#{bundle['notification.dataset.management.title']}" target="_blank">#{bundle['header.guides.user']}</a>
                                                        </o:param>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'SUBMITTEDDS'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.wasSubmittedForReview']}" escape="false">
                                                        <o:param>
                                                            <a href="/dataset.xhtml?persistentId=#{item.theObject.getDataset().getGlobalId()}&amp;version=DRAFT&amp;faces-redirect=true" title="#{item.theObject.getDataset().getDisplayName()}">#{item.theObject.getDataset().getDisplayName()}</a>
                                                        </o:param>
                                                        <o:param>
                                                            <a href="/dataverse/#{item.theObject.getDataset().getOwner().getAlias()}" title="#{item.theObject.getDataset().getOwner().getDisplayName()}">#{item.theObject.getDataset().getOwner().getDisplayName()}</a>
                                                        </o:param>
                                                        <o:param>
                                                            #{DataverseUserPage.getRequestorName(item)}
                                                        </o:param>
                                                        <o:param>
                                                            #{DataverseUserPage.getRequestorEmail(item)}
                                                        </o:param>
                                                        <o:param>
                                                            #{DataverseUserPage.getReasonForReturn(item.theObject)}
                                                        </o:param>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'RETURNEDDS'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.wasReturnedByReviewer']}" escape="false">
                                                        <o:param>
                                                            <a href="/dataset.xhtml?persistentId=#{item.theObject.getDataset().getGlobalId()}&amp;version=DRAFT&amp;faces-redirect=true" title="#{item.theObject.getDataset().getDisplayName()}">#{item.theObject.getDataset().getDisplayName()}</a>
                                                        </o:param>
                                                        <o:param>
                                                            <a href="/dataverse/#{item.theObject.getDataset().getOwner().getAlias()}" title="#{item.theObject.getDataset().getOwner().getDisplayName()}">#{item.theObject.getDataset().getOwner().getDisplayName()}</a>
                                                        </o:param>
                                                        <!-- Reason for Return - This needs some work in the DataverseUserPage method to get it to work -->
                                                        <ui:remove>
                                                        <o:param>
                                                            #{DataverseUserPage.getReasonForReturn(item.theObject)}
                                                        </o:param>
                                                        </ui:remove>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'PUBLISHEDDS'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.wasPublished']}" escape="false">
                                                        <o:param>
                                                            <a href="/dataset.xhtml?persistentId=#{item.theObject.getDataset().getGlobalId()}&amp;version=DRAFT&amp;faces-redirect=true" title="#{item.theObject.getDataset().getDisplayName()}">#{item.theObject.getDataset().getDisplayName()}</a>
                                                        </o:param>
                                                        <o:param>
                                                            <a href="/dataverse/#{item.theObject.getDataset().getOwner().getAlias()}" title="#{item.theObject.getDataset().getOwner().getDisplayName()}">#{item.theObject.getDataset().getOwner().getDisplayName()}</a>
                                                        </o:param>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'REQUESTFILEACCESS'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.requestFileAccess']}" escape="false">
                                                        <o:param>
                                                            <a href="/permissions-manage-files.xhtml?id=#{item.theObject.id}" title="#{item.theObject.displayName}">#{item.theObject.displayName}</a>
                                                        </o:param>
                                                        <o:param>
                                                            #{DataverseUserPage.getRequestorName(item)}
                                                        </o:param>
                                                        <o:param>
                                                            #{DataverseUserPage.getRequestorEmail(item)}
                                                        </o:param>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'GRANTFILEACCESS'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.grantFileAccess']}" escape="false">
                                                        <o:param>
                                                            <a href="/dataset.xhtml?persistentId=#{item.theObject.getGlobalId()}" title="#{item.theObject.displayName}">#{item.theObject.displayName}</a>
                                                        </o:param>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'REJECTFILEACCESS'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.rejectFileAccess']}" escape="false">
                                                        <o:param>
                                                            <a href="/dataset.xhtml?persistentId=#{item.theObject.getGlobalId()}" title="#{item.theObject.displayName}">#{item.theObject.displayName}</a>
                                                        </o:param>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'MAPLAYERUPDATED'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.worldMap.added']}" escape="false">
                                                        <o:param>
                                                            <a href="/dataset.xhtml?persistentId=#{item.theObject.getDataset().getGlobalId()}" title="#{item.theObject.getDataset().getDisplayName()}">#{item.theObject.getDataset().getDisplayName()}</a>
                                                        </o:param>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'MAPLAYERDELETEFAILED'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.maplayer.deletefailed']}" escape="false">
                                                        <o:param value="#{item.theObject.getLabel()}"/>
                                                        <o:param>
                                                            <a href="/dataset.xhtml?persistentId=#{item.theObject.getDatasetVersion().getDataset().getGlobalId()}" title="#{item.theObject.getDatasetVersion().getDataset().getDisplayName()}">#{item.theObject.getDatasetVersion().getDataset().getDisplayName()}</a>
                                                        </o:param>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'ASSIGNROLE'}">
                                                    <ui:fragment rendered="#{item.theObject.isInstanceofDataverse()}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.access.granted.dataverse']}" escape="false">
                                                        <o:param value="#{item.roleString}"/>
                                                        <o:param>
                                                            <a href="/dataverse/#{item.theObject.getAlias()}" title="#{item.theObject.getDisplayName()}">#{item.theObject.getDisplayName()}</a>
                                                        </o:param>
                                                    </h:outputFormat>
                                                    <ui:fragment rendered="#{item.roleString == 'File Downloader'}">
                                                        <h:outputFormat value="#{bundle['notification.access.granted.fileDownloader.additionalDataverse']}" escape="false">
                                                            <f:param value=" "/>
                                                        </h:outputFormat>
                                                    </ui:fragment>
                                                    </ui:fragment>
                                                    <ui:fragment rendered="#{item.theObject.isInstanceofDataset()}">
                                                        <span class="icon-dataset text-icon-inline text-muted"></span>
                                                        <h:outputFormat value="#{bundle['notification.access.granted.dataset']}" escape="false">
                                                            <o:param value="#{item.roleString}"/>
                                                            <o:param>
                                                                <a href="/dataset.xhtml?persistentId=#{item.theObject.getGlobalId()}" title="#{item.theObject.getDisplayName()}">#{item.theObject.getDisplayName()}</a>
                                                            </o:param>
                                                        </h:outputFormat>
                                                        <ui:fragment rendered="#{item.roleString == 'File Downloader'}">
                                                            <h:outputText value="" />
                                                            <h:outputFormat value="#{bundle['notification.access.granted.fileDownloader.additionalDataset']}" escape="false">
                                                                <f:param value=" "/>
                                                            </h:outputFormat>
                                                    </ui:fragment>
                                                    </ui:fragment>
                                                    <ui:fragment rendered="#{item.theObject.isInstanceofDataFile()}">
                                                    <f:param value="#{item.roleString}"/>
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.access.granted.datafile']}" escape="false">
                                                            <o:param value="#{item.roleString}"/>
                                                            <o:param>
                                                                <a href="/dataset.xhtml?persistentId=#{item.theObject.getOwner().getGlobalId()}" title="#{item.theObject.getOwner().getDisplayName()}">#{item.theObject.getOwner().getDisplayName()}</a>
                                                            </o:param>
                                                    </h:outputFormat>
                                                    </ui:fragment>

                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'REVOKEROLE'}">
                                                    <ui:fragment rendered="#{item.theObject.isInstanceofDataverse()}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.access.revoked.dataverse']}" escape="false">
                                                            <o:param>
                                                                <a href="/dataverse/#{item.theObject.getAlias()}" title="#{item.theObject.getDisplayName()}">#{item.theObject.getDisplayName()}</a>
                                                            </o:param>
                                                    </h:outputFormat>
                                                    </ui:fragment>
                                                    <ui:fragment rendered="#{item.theObject.isInstanceofDataset()}">
                                                    <f:param value="#{item.roleString}"/>
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.access.revoked.dataset']}" escape="false">
                                                        <o:param>
                                                                <a href="/dataset.xhtml?persistentId=#{item.theObject.getGlobalId()}" title="#{item.theObject.getDisplayName()}">#{item.theObject.getDisplayName()}</a>
                                                        </o:param>
                                                    </h:outputFormat>
                                                    </ui:fragment>
                                                    <ui:fragment rendered="#{item.theObject.isInstanceofDataFile()}">
                                                    <f:param value="#{item.roleString}"/>
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.access.revoked.datafile']}" escape="false">
                                                        <o:param>
                                                              <a href="/dataset.xhtml?persistentId=#{item.theObject.getOwner().getGlobalId()}" title="#{item.theObject.getOwner().getDisplayName()}">#{item.theObject.getOwner().getDisplayName()}</a>
                                                        </o:param>
                                                    </h:outputFormat>
                                                    </ui:fragment>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'CHECKSUMFAIL'}">
                                                    <!--
                                                    TODO: Rather than matching on hard-coded strings such as "CHECKSUMFAIL"
                                                    a more type-safe approach would be to use the "Type" enum in UserNotification.
                                                    Also, isInstanceofDataset() should be checked, probably.
                                                    -->
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.checksumfail']}" escape="false">
                                                        <f:param value="#{item.theObject.getGlobalId()}"/>
                                                        <f:param value="#{item.theObject.getDisplayName()}"/>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'FILESYSTEMIMPORT'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.import.filesystem']}" escape="false">
                                                        <f:param value="#{item.theObject.getDataset().getGlobalId()}"/>
                                                        <f:param value="#{item.theObject.getDataset().getDisplayName()}"/>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'CHECKSUMIMPORT'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.import.checksum']}" escape="false">
                                                        <f:param value="#{item.theObject.getDataset().getGlobalId()}"/>
                                                        <f:param value="#{item.theObject.getDataset().getDisplayName()}"/>
                                                    </h:outputFormat>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{item.type == 'APIGENERATED'}">
                                                    <span class="icon-dataset text-icon-inline text-muted"></span>
                                                    <h:outputFormat value="#{bundle['notification.email.apiTokenGenerated.subject']}" escape="false">
                                                    </h:outputFormat>
                                                </ui:fragment>

                                            </ui:fragment>
                                            <h:outputText value="#{item.localeSendDate}" styleClass="text-muted small"/>
                                        </div>
                                        <div class="notification-item-cell">
                                            <p:commandLink title="#{bundle.removeNotification}" styleClass="bootstrap-button-tooltip"
                                                           action="#{DataverseUserPage.remove(item.id)}" update="@form"
                                                           oncomplete="bind_bsui_components();">
                                                <span class="glyphicon glyphicon-remove"></span>
                                            </p:commandLink>
                                        </div>
                                    </div>
                                </ui:repeat>
                            </div>
                        </p:tab>
                        <p:tab id="accountInfo" title="#{bundle['header.user.selectTab.accountInfo']}">
                            <div class="form-horizontal" jsf:rendered="#{!empty DataverseUserPage.currentUser}">
                                <div class="form-group" jsf:rendered="#{not DataverseUserPage.accountDetailsEditable}">
                                    <div class="col-sm-12">
                                        <p class="help-block">
                                            <h:outputText value="#{bundle['user.isShibUser']}" />
                                            <h:outputText value=" #{bundle['user.helpShibUserMigrateOffShibBeforeLink']} " />
                                            <p:commandLink value="#{settingsWrapper.supportTeamName}" oncomplete="PF('contactForm').show()" update=":contactDialog" actionListener="#{sendFeedbackDialog.initUserInput}">
                                                <f:setPropertyActionListener target="#{sendFeedbackDialog.messageSubject}" value=""/>
                                                <f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{null}"/>
                                                <f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
                                                <f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
                                            </p:commandLink>
                                            <h:outputText value=" #{bundle['user.helpShibUserMigrateOffShibAfterLink']}" />
                                        </p>
                                    </div>
                                </div>
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.userAuthProvider.OAuthProvider}">
                                    <div class="col-sm-12">
                                        <p class="help-block">
                                            <h:outputFormat value="#{bundle['user.helpOAuthBeforeLink']} ">
                                                <f:param value="#{DataverseUserPage.userAuthProvider.info.title}"/>
                                            </h:outputFormat>
                                            <p:commandLink value="#{settingsWrapper.supportTeamName}" oncomplete="PF('contactForm').show()" update=":contactDialog" actionListener="#{sendFeedbackDialog.initUserInput}">
                                                <f:setPropertyActionListener target="#{sendFeedbackDialog.messageSubject}" value=""/>
                                                <f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{null}"/>
                                                <f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
                                                <f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
                                            </p:commandLink>
                                            <h:outputText value=" #{bundle['user.helpOAuthAfterLink']}" />
                                        </p>
                                    </div>
                                </div>
                                <!-- Username -->
                                <div class="form-group">
                                    <label for="userNameEmail" class="col-sm-3 control-label">
                                        #{bundle['user.username']}
                                    </label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">#{DataverseUserPage.currentUser.identifier.replaceFirst("@", "")}</p>
                                    </div>
                                </div>
                                <!-- First Name -->
                                <div class="form-group">
                                    <label for="firstName" class="col-sm-3 control-label">
                                        #{bundle['user.firstName']}
                                    </label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">#{DataverseUserPage.currentUser.firstName}</p>
                                    </div>
                                </div>
                                <!-- Last Name -->
                                <div class="form-group">
                                    <label for="lastName" class="col-sm-3 control-label">
                                        #{bundle['user.lastName']}
                                    </label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">#{DataverseUserPage.currentUser.lastName}</p>
                                    </div>
                                </div>
                                <!-- Email -->
                                <div class="form-group">
                                    <label for="email" class="col-sm-3 control-label">
                                        #{bundle.email}
                                    </label>
                                    <div class="col-sm-9 form-col-container">
                                        <div class="col-sm-4 form-col-container">
                                            <p class="form-control-static">#{DataverseUserPage.currentUser.email}</p>
                                        </div>
                                        <!-- modify by yqpeng2, 2019-12-26 不需要对邮件进行验证 -->
                                        <!--<div class="col-sm-2 form-col-container" style="display: none;">
                                            <p class="form-control-static #{DataverseUserPage.emailIsVerified ? 'text-success' : 'text-danger'}">
                                                <ui:fragment rendered="#{DataverseUserPage.emailNotVerified}">
                                                    <span class="glyphicon glyphicon-ban-circle"/> #{bundle['confirmEmail.notVerified']}
                                                </ui:fragment>
                                                <ui:fragment rendered="#{!DataverseUserPage.emailNotVerified}">
                                                    <span class="glyphicon glyphicon-ok"/> #{bundle['confirmEmail.verified']}
                                                </ui:fragment>
                                            </p>
                                        </div>
                                        <div class="col-sm-1">
                                            <h:commandLink rendered="#{DataverseUserPage.showVerifyEmailButton()}" styleClass="btn btn-default" action="#{DataverseUserPage.sendConfirmEmail()}">
                                                <span class="glyphicon glyphicon-ok"></span> #{bundle['confirmEmail.submitRequest']}
                                            </h:commandLink>
                                        </div>-->
                                    </div>
                                </div>
                                <!-- ORCID iD, for example -->
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.userAuthProvider.displayIdentifier}">
                                    <label for="userPersistentId" class="col-sm-3 control-label">
                                        #{DataverseUserPage.userAuthProvider.persistentIdName}
                                    </label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">
                                            <h:graphicImage value="#{DataverseUserPage.userAuthProvider.logo}" height="16" width="16" alt="#{of:format1(bundle['alt.logo'], DataverseUserPage.userAuthProvider.persistentIdName)}"/>&#160;
                                            <h:outputLink value="#{DataverseUserPage.userAuthProvider.persistentIdUrlPrefix}#{DataverseUserPage.currentUser.authenticatedUserLookup.persistentUserId}" title="#{DataverseUserPage.userAuthProvider.persistentIdName}" target="_blank">
                                                <h:outputText value="#{DataverseUserPage.userAuthProvider.persistentIdUrlPrefix}#{DataverseUserPage.currentUser.authenticatedUserLookup.persistentUserId}"/>
                                            </h:outputLink>
                                        </p>
                                    </div>
                                </div>
                                <!-- Affiliation -->
                                <div class="form-group" jsf:rendered="#{!empty DataverseUserPage.currentUser.affiliation}">
                                    <label for="affiliation" class="col-sm-3 control-label">
                                        #{bundle.affiliation}
                                    </label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">#{DataverseUserPage.currentUser.affiliation}</p>
                                    </div>
                                </div>
                                <!-- Position (not populated for Shibboleth users) -->
                                <div class="form-group" jsf:rendered="#{!empty DataverseUserPage.currentUser.position}">
                                    <label for="position" class="col-sm-3 control-label">
                                        #{bundle['user.position']}
                                    </label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">#{DataverseUserPage.currentUser.position}</p>
                                    </div>
                                </div>
                            </div>
                        </p:tab>
                        <p:tab id="apiTokenTab" title="#{bundle['apitoken.title']}">
                            <p class="help-block">
                                <h:outputFormat value="#{bundle['apitoken.message']}" escape="false">
                                    <f:param value="&lt;a href=&#34;#{systemConfig.guidesBaseUrl}/#{systemConfig.guidesVersion}/api&#34; target=&#34;_blank&#34;&gt;"/>
                                    <f:param value="&lt;/a&gt;"/>
                                </h:outputFormat>
                            </p>
                            <div id="apiToken" class="highlight hidden">
                                 <pre>
                                    <code class="language-html" data-lang="html">${ApiTokenPage.apiToken}</code>
                                 </pre>
                            </div>
                            <!--Script removes "hidden" class from div containing API token to stop javascript browser exploits-->
                            <script>
                                //<![CDATA[
                                $(document).ready(function() {
                                    $("div#apiToken").removeClass("hidden");
                                });
                                //Produces "Are you sure you want to leave this page?" alert to allow API token to hide again
                                $(window).on("beforeunload", function() {
                                    $("div#apiToken").addClass("hidden");
                                });
                                //]]>
                            </script>
                            <div>
                                <button class="btn btn-default" jsf:action="#{ApiTokenPage.generate()}">
                                    #{ApiTokenPage.checkForApiToken() ? bundle['apitoken.regenerateBtn'] : bundle['apitoken.generateBtn']}
                                </button>
                            </div>
                        </p:tab>
                        <ui:remove>
                            <p:tab id="groupsRoles" title="#{bundle['header.user.selectTab.groupsAndRoles']}">
                                #{bundle['groupAndRoles.manageTips']}
                            </p:tab>
                        </ui:remove>
                    </p:tabView>

                    <p:tabView id="accountInfoView" rendered="#{!empty DataverseUserPage.editMode}">
                        <p:tab id="accountInfoEdit" title="#{bundle['account.info']}">
                            <ui:fragment rendered="#{DataverseUserPage.editMode == 'CREATE' and DataverseUserPage.nonLocalLoginEnabled}">
                                <p class="help-block">
                                    <h:outputText value="#{bundle['user.signup.otherLogInOptions.tip']}" escape="false"/>
                                </p>
                            </ui:fragment>
                            <div class="form-horizontal">
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.editMode == 'CREATE' or DataverseUserPage.editMode == 'EDIT'}">
                                <!-- Username -->
                                    <label for="userNameEmail" class="col-sm-3 control-label">
                                        #{bundle['user.username']} <span class="glyphicon glyphicon-asterisk text-danger"/>
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['user.username.illegal.tip']}"></span>
                                    </label>
                                    <div class="col-sm-9">
                                        <p class="help-block">#{bundle['user.username.valid']}</p>
                                    </div>
                                    <div class="col-sm-4 col-sm-offset-3">
                                        <p:inputText id="userName" styleClass="form-control"
                                                        validator="#{DataverseUserPage.validateUserName}"
                                                        value="#{DataverseUserPage.username}"
                                                        disabled="#{DataverseUserPage.editMode != 'CREATE'}"
                                                        binding="#{DataverseUserPage.usernameField}"/>
                                        <p:message for="userName" display="text" />
                                    </div>
                                </div>
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.editMode == DataverseUserPage.changePasswordMode}">
                                <!-- Current Password -->
                                    <label for="currentPassword" class="col-sm-3 control-label">
                                        #{bundle['user.currentPasswd']} <span class="glyphicon glyphicon-asterisk text-danger"/>
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['user.currentPasswd.tip']}"></span>
                                    </label>
                                    <div class="col-sm-4">
                                        <p:password id="currentPassword" label="#{bundle['user.currentPasswd']}" styleClass="form-control" value="#{DataverseUserPage.currentPassword}" autocomplete="off"/><!-- browsers will in general not respect autocomplete="foo", but scanners will still flag it as a potential problem -->
                                        <p:message for="currentPassword" display="text" />
                                    </div>
                                </div>
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.editMode == 'CREATE' or DataverseUserPage.editMode == DataverseUserPage.changePasswordMode}">
                                <!-- Password -->
                                    <label for="inputPassword" class="col-sm-3 control-label">
                                        <h:outputText value="#{DataverseUserPage.editMode == 'CREATE' ? bundle['user.password'] : bundle['user.newPassword']}" />
                                        <span class="glyphicon glyphicon-asterisk text-danger"></span>
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['user.passwd.illegal.tip']}"></span>
                                    </label>
                                    <div class="col-sm-9">
                                        <div class="help-block">
                                            <h:outputFormat value="#{bundle['user.updatePassword.password']}" escape="false">
                                                <f:param value="#{DataverseUserPage.passwordRequirements}"/>
                                            </h:outputFormat>
                                        </div>
                                    </div>
                                    <div class="col-sm-4 col-sm-offset-3">
                                        <p:password id="inputPassword" label="#{DataverseUserPage.editMode == 'CREATE' ? bundle['user.password'] : bundle['user.newPassword']}" styleClass="form-control" match="retypePassword" value="#{DataverseUserPage.inputPassword}" validator="#{DataverseUserPage.validateNewPassword}" autocomplete="off"/><!-- browsers will in general not respect autocomplete="foo", but scanners will still flag it as a potential problem -->
                                        <p:message for="inputPassword" display="text" />
                                    </div>
                                </div>
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.editMode == 'CREATE' or DataverseUserPage.editMode == DataverseUserPage.changePasswordMode}">
                                    <!-- Retype Password -->
                                    <label for="retypePassword" class="col-sm-3 control-label">
                                        #{bundle['user.rePasswd']} <span class="glyphicon glyphicon-asterisk text-danger"/>
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['user.rePasswd.tip']}"></span>
                                    </label>
                                    <div class="col-sm-4">
                                        <p:password id="retypePassword" label="#{bundle['user.rePasswd']}" styleClass="form-control" value="#{DataverseUserPage.inputPassword}" autocomplete="off"/><!-- browsers will in general not respect autocomplete="foo", but scanners will still flag it as a potential problem -->
                                        <p:message for="retypePassword" display="text" />
                                    </div>
                                </div>
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.editMode == 'CREATE' or DataverseUserPage.editMode == 'EDIT'}">
                                <!-- First Name -->
                                    <label for="firstName" class="col-sm-3 control-label">
                                        #{bundle['user.firstName']} <span class="glyphicon glyphicon-asterisk text-danger"/>
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['user.firstName.tip']}"></span>
                                    </label>
                                    <div class="col-sm-4">
                                        <p:inputText id="firstName" styleClass="form-control" value="#{DataverseUserPage.userDisplayInfo.firstName}" />
                                        <p:message for="firstName" display="text" />
                                    </div>
                                </div>
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.editMode == 'CREATE' or DataverseUserPage.editMode == 'EDIT'}">
                                    <!-- Last Name -->
                                    <label for="lastName" class="col-sm-3 control-label">
                                        #{bundle['user.lastName']} <span class="glyphicon glyphicon-asterisk text-danger"/>
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['user.lastName.tip']}"></span>
                                    </label>
                                    <div class="col-sm-4">
                                        <p:inputText id="lastName" styleClass="form-control" value="#{DataverseUserPage.userDisplayInfo.lastName}" />
                                        <p:message for="lastName" display="text" />
                                    </div>
                                </div>
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.editMode == 'CREATE' or DataverseUserPage.editMode == 'EDIT'}">
                                    <!-- Email -->
                                    <label for="email" class="col-sm-3 control-label">
                                        #{bundle.email} <span class="glyphicon glyphicon-asterisk text-danger"/>
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['user.email.tip']}"></span>
                                    </label>
                                    <div class="col-sm-4">
                                        <p:inputText id="email" styleClass="form-control"
                                                     validator="#{DataverseUserPage.validateUserEmail}"
                                                     value="#{DataverseUserPage.userDisplayInfo.emailAddress}" />
                                        <p:message for="email" display="text" />
                                    </div>
                                </div>
                                <!--FIXME: refactor to remove need for EDIT? userAuthProvider is null on CREATE-->
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.editMode == 'EDIT' and DataverseUserPage.userAuthProvider.displayIdentifier}">
                                    <!-- ORCID iD, for example -->
                                    <label for="userPersistentId" class="col-sm-3 control-label">
                                        #{DataverseUserPage.userAuthProvider.persistentIdName}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{DataverseUserPage.userAuthProvider.persistentIdDescription}"></span>
                                    </label>
                                    <div class="col-sm-4">
                                        <p class="form-control-static">
                                            <h:graphicImage value="#{DataverseUserPage.userAuthProvider.logo}" height="16" width="16" alt="#{of:format1(bundle['alt.logo'], DataverseUserPage.userAuthProvider.persistentIdName)}"/>&#160;
                                            <h:outputLink value="#{DataverseUserPage.userAuthProvider.persistentIdUrlPrefix}#{DataverseUserPage.currentUser.authenticatedUserLookup.persistentUserId}" title="#{DataverseUserPage.userAuthProvider.persistentIdName}" target="_blank">
                                                <h:outputText value="#{DataverseUserPage.userAuthProvider.persistentIdUrlPrefix}#{DataverseUserPage.currentUser.authenticatedUserLookup.persistentUserId}"/>
                                            </h:outputLink>
                                        </p>
                                    </div>
                                </div>
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.editMode == 'CREATE' or DataverseUserPage.editMode == 'EDIT'}">
                                    <!-- Affiliation -->
                                    <label for="affiliation" class="col-sm-3 control-label">
                                        #{bundle.affiliation}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['user.affiliation.tip']}"></span>
                                    </label>
                                    <div class="col-sm-4">
                                        <p:inputText id="affiliation" styleClass="form-control" value="#{DataverseUserPage.userDisplayInfo.affiliation}" />
                                        <p:message for="affiliation" display="text" />
                                    </div>
                                </div>
                                <div class="form-group" jsf:rendered="#{DataverseUserPage.editMode == 'CREATE' or DataverseUserPage.editMode == 'EDIT'}">
                                <!-- Position -->
                                    <label for="position" class="col-sm-3 control-label">
                                        #{bundle['user.position']}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['user.position.tip']}"></span>
                                    </label>
                                    <div class="col-sm-4">
                                        <p:inputText id="position" styleClass="form-control" value="#{DataverseUserPage.userDisplayInfo.position}" />
                                        <p:message for="position" display="text" />
                                    </div>
                                </div>
                                <ui:fragment rendered="#{DataverseUserPage.editMode == 'CREATE'}">
                                <!-- Terms of Use -->
                                    <ui:include src="termsofuse.xhtml"/>
                                </ui:fragment>
                                <div class="form-group">
                                    <div class="col-sm-12 button-block">
                                        <p:commandButton id="save" styleClass="btn btn-default"
                                                         value="#{DataverseUserPage.editMode == 'CREATE' ? bundle['user.createBtn']:bundle.saveChanges}"
                                                         action="#{DataverseUserPage.save}" update="@form,:messagePanel,:userDisplayInfoTitle"/>
                                        <p:commandButton id="cancel" styleClass="btn btn-link" value="#{bundle.cancel}"
                                                         action="#{DataverseUserPage.cancel}" process="@this" update="@form">
                                            <p:resetInput target="@form"/>
                                        </p:commandButton>
                                    </div>
                                </div>
                            </div>
                        </p:tab>
                    </p:tabView>
                </h:form>
            </ui:define>
        </ui:composition>

    </h:body>
</html>
